﻿using System.Activities;
using Microsoft.Xrm.Sdk.Workflow;

namespace Utils
{
    public sealed class Whitespace : CodeActivity
    {

        [Input("Number of Whitespaces")]
        [Default("1")]
        public InArgument<int> NumberOfWhitespaces { get; set; }

        [Output("Whitespaces")]
        [Default(" ")]
        public OutArgument<string> Whitespaces { get; set; }

        protected override void Execute(CodeActivityContext executionContext)
        {
            int numberOfWhitespaces = NumberOfWhitespaces.Get<int>(executionContext);
            if (numberOfWhitespaces < 0) { numberOfWhitespaces = 0; }
            string whitespaces = new string(' ', numberOfWhitespaces);
            Whitespaces.Set(executionContext, whitespaces);
        }
    }
}

